home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
handle20.zip
/
FILES33.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-07-17
|
17KB
|
336 lines
;****************************************************************************
; file: files33.asm by: Steven M. Gibson, Irvine, CA created: 06/06/87
;****************************************************************************
;
; * * * PUBLIC DOMAIN COPYRIGHT RELEASE NOTICE * * *
;
; THIS PROGRAM, IN BOTH SOURCE CODE AND OBJECT FORM, HAS BEEN EXPLICITLY
; PLACED INTO THE PUBLIC DOMAIN BY ITS SOLE AUTHOR AND OWNER, STEVEN GIBSON,
; OF IRVINE, CA. IT MAY THEREFORE BE FREELY REPRODUCED, EXCHANGED, UPLOADED
; AND DOWNLOADED. HOWEVER THE AUTHOR REQUESTS THAT THIS NOTICE OF RELEASE
; AND ORIGIN OF AUTHORSHIP BE LEFT INTACT AND THAT THIS PROGRAM OR ITS DIRECT
; DERRIVATIVES, IF ANY, *NOT* BE SOLD FOR PROFIT. ALSO, PLEASE KEEP THE
; ENTIRE SET OF FILES TOGETHER AS ONE PACKAGE. ----> Thanks
;
;****************************************************************************
;
; About The Program: FILES.COM (source code file: files33.asm)
;
; "FILES.COM" is a small resident (TSR) program which overcomes a major
; glitch in the way IBM has implemented DOS 3.30. Specifically, it handles
; the requirements of explicitly ASKING DOS for additional handles and
; keeping a block of RAM available for DOS when this request is made.
; Any program can now have up to 256 files open when under 3.3 (counting
; the standard pre-opened default files) if the command "FILES" is issued
; first. This program also has the interesting ability to spontaneously
; remove itself ("Un-TSR") from memory after doing its job.
;
; If you wish to suppress the message FILES delivers when it is run, simply
; put anything after the command, (like: "files shhh") and it won't say a
; word as it goes resident. Otherwise it makes a short (non-commercial)
; statement of its intent as it terminates.
;
; NOTE: This program *ONLY* makes sense when under version 3.3 of DOS, and
; it will refuse to run under any earlier DOS versions. Use the
; other DOS 3.x version of FILES.COM (source file: files3x.asm)
;****************************************************************************
;
; About These SOURCE CODE FILES:
;
; This source code file, and the companion OPENER.ASM source code file, were
; written to be instructional, clear, and a bit tutorial in nature. As such
; they have been commented more heavily than normal self-communication
; would normally dictate. I hope you will find them interesting, useful,
; and not overly verbose. They are also examples of a general coding style
; I've found to endure quite well. Adopt it if you like it.
;
; NOTE: These files were created using the incredible file editor: BRIEF
;
;****************************************************************************
;
; To make a COM file from this ASM source code:
;
; masm files33, files33; <--- assemble the .asm to .obj
; link files33; <--- link the .obj to .exe
; exe2bin files33 files33.com <--- convert .exe to .com
; del files33.obj <--- delete the intermediate debris
; del files33.exe
;
;****************************************************************************
;----------------------------------------------------------------------------
; E Q U A T E S
;----------------------------------------------------------------------------
CR equ 0Dh ; ASCII
LF equ 0Ah
COM_TERMINATE equ 20h ; .COM program termination
DOS_FUNC equ 21h ; Interrupt to call DOS
DOS_PRINTSTRING equ 09h ; Dos Sub-Function Defs
DOS_SET_VECTOR equ 25h
DOS_VERSION_NUMBER equ 30h ; " "
DOS_STAY_RESIDENT equ 31h
DOS_GET_VECTOR equ 35h
DOS_CREATE equ 3Ch ; " "
DOS_OPEN equ 3DH
DOS_ALLOC equ 48H
DOS_DEALLOC equ 49H ; " "
DOS_SETBLOCK equ 4AH
DOS_EXEC equ 4BH
SET_HANDLE_COUNT equ 67h ; <----- The *NEW* function!
NEW_HANDLE_COUNT equ 256 + 1 ; so we cam have 256 files
NEW_MAX_HANDLES equ 256 ; assuming 256 handle params
MINIMUM_VERSION equ 3 * 256 + 30 ; version "3"."30"
;----------------------------------------------------------------------------
; C O D E S E G M E N T
;----------------------------------------------------------------------------
CODESEG SEGMENT BYTE PUBLIC
ASSUME CS:CODESEG, DS:CODESEG
ORG 02Ch ; pointer to this program's environ
Environment LABEL WORD
ORG 080h
ParameterCount LABEL BYTE ; count of the command-line params
ORG 100h ; .com programs execute from 0100h
ComStart: jmp TransientCode ; jump over our resident portion
;****************************************************************************
; RESIDENT CODE PORTION BEGINS HERE
;****************************************************************************
OldDosInt dd ? ; original int 21 vector pointer
TriggerEnable db 0 ; non-zero after enabling EXEC call
HoleSegment dw ? ; segment location of the "hole"
;----------------------------------------------------------------------------
;----------------------------------------------------------------------------
; NOTE TO THE READER: The following "resident portion" of the TSR will make
; *MUCH* more sense if you have FIRST read the "transient portion" below. I
; suggest that you jump ahead and read that first, then come back to here....
;----------------------------------------------------------------------------
Int21Intercept:
;----------------------------------------------------------------------------
; The transient portion of this program pointed DOS' calling Interrupt 21
; here before terminating itself. Therefore we receive control every time
; anyone does an Int21h call to DOS. (Until we've fulfilled our mission)
;----------------------------------------------------------------------------
cmp ah, DOS_EXEC ; is DOS starting a program?
jne NotEnablingCall ; nope, so skip the enabling
mov cs:TriggerEnable, -1 ; yes!, so we simply enable
jmp Int21Continue ; and resume Int21 monitoring
NotEnablingCall:cmp ah, DOS_OPEN ; was the call an open handle?
je SeeIfReady ; yep, are we ready to go?
cmp ah, DOS_CREATE ; was it a create handle?
jne Int21Continue ; nope, so we keep waiting...
SeeIfReady: cmp cs:TriggerEnable, 0 ; have we been enabled by EXEC
je Int21Continue ; nope, so ignore the OPEN
cmp cs:HoleSegment, 0 ; did we already do our thing?
je Int21Continue ; yep, so don't do it again!
push ax ; save the caller's calling
push bx ; parameters on "his" stack
push es
;----------------------------------------------------------------------------
; Free up the memory block, located at "HoleSegment", which was previously
; allocated by the transient portion of this program.
;----------------------------------------------------------------------------
mov es, cs:HoleSegment ; get the segment number
mov cs:HoleSegment, 0 ; zero it so we don't again
mov ah, DOS_DEALLOC
int DOS_FUNC ; and release that ram block
;----------------------------------------------------------------------------
; Now use DOS 3.3's new function: "Set Handle Count" to get DOS to use the
; RAM memory we've just now freed up for the purpose of allowing the handles
;----------------------------------------------------------------------------
mov ah, SET_HANDLE_COUNT ; ask DOS for mucho handles
mov bx, NEW_HANDLE_COUNT ; using the new 3.3 function
int DOS_FUNC
;----------------------------------------------------------------------------
; Now we verrify that interrupt 21 is still pointing at us, and if so
; we're able to re-point it to where it was originally pointing, (thus
; un-vectoring ourselves) then release even ourselves from ram too!
;----------------------------------------------------------------------------
mov ah, DOS_GET_VECTOR
mov al, DOS_FUNC ; get int 21's address
int DOS_FUNC
cmp bx, OFFSET Int21Intercept
jne RestoreStack ; it moved, so we must remain
mov ax, es ;
mov bx, cs ; can't compare segment regs,
cmp ax, bx ; <sigh> so we do it this way
jne RestoreStack
;---------------------------------------